package com.ceres.farm.dao;

import com.ceres.crops.pojo.Crops;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface CropsMapper   {
    //根据农作物名称和生长状态查询
    @Select("SELECT id,opt_range FROM t_crops_index WHERE cid=(SELECT id FROM t_crops WHERE `name`=#{name} AND stage=#{stage})")
      List< Map<String,Object>> findIndex(@Param("name") String name,@Param("stage") String stage);
    //根据ID查询指标名
    @Select("SELECT index_type FROM t_index WHERE id=#{id}")
    String findIndexType(Integer id);
    //根据农作物查询害虫
    @Select("SELECT pest FROM t_crops_disease WHERE crops=#{crops}")
    List<String> findPest(String crops);
    //根据农作物名称查询成长阶段
    @Select("SELECT stage FROM t_crops WHERE `name`=#{cname}")
    List<String> findStageByCrops(String cname);
}
